package com.lk.base.config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class PropConf {
	
	public static Map<String,String> propsMap = new HashMap<>();

	
	static {
		Properties properties = new Properties();
	    // 使用ClassLoader加载properties配置文件生成对应的输入流
	    InputStream in = PropConf.class.getClassLoader().getResourceAsStream("config.properties");
	    // 使用properties对象加载输入流
	    try {
			properties.load(in);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    //获取key对应的value值
	    Enumeration en = properties.propertyNames();
        while (en.hasMoreElements())
        {
            String key = (String) en.nextElement();
            String value = properties.getProperty(key);
            System.out.println(key + " : " + value);
            
            propsMap.put(key, value);
        }
	}
	

	public static Integer getIntValueByKey(String key) {
		return Integer.parseInt(getValueByKey(key));
	}
	
	public static String getValueByKey(String key) {
		return propsMap.get(key);
	}
    
    
}
